<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      layout:decorate="~{admin/layout}">
<body>

<div class="content-wrap" layout:fragment="content">
    <main id="content" class="content" role="main">
        <ol class="breadcrumb">
            <li>财务管理</li>
            <li class="active">号苗管理</li>
        </ol>
        <section class="widget">
            <header>
                <div class="widget-controls">
                    <a data-widgster="expand" title="Expand" href="#"><i class="glyphicon glyphicon-chevron-up"></i></a>
                    <a data-widgster="collapse" title="Collapse" href="#"><i class="glyphicon glyphicon-chevron-down"></i></a>
                    <a data-widgster="close" title="Close" href="#"><i class="glyphicon glyphicon-remove"></i></a>
                </div>
            </header>
            <div class="widget-body">
                <div class="mt">
                    <table id="datatable-table" class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th class="hidden-sm-down">去向</th>
                            <th class="hidden-sm-down">位置</th>
                            <th class="hidden-sm-down">号苗数量</th>
                            <th class="hidden-sm-down">树种</th>
                            <th class="no-sort">过期时间</th>
                            <shiro:hasAnyRoles name="admin,finance">
                                <th class="no-sort">解锁</th>
                            </shiro:hasAnyRoles>
                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="tree:${trees}">
                            <td th:text="${tree.remark}"></td>
                            <td th:text="${tree.serialNumber}"></td>
                            <td th:text="${tree.number}"></td>
                            <td class="hidden-sm-down" th:text="${tree.treeSpecies}"></td>
                            <td class="hidden-sm-down" th:text="*{#dates.format(tree.createtime,'yyyy-MM-dd')}"></td>
                            <shiro:hasAnyRoles name="admin,finance">
                             <td>
                                 <a  th:href="@{/admin/finance/deblocking(tree_id=${tree.tree_id})}">全部解锁</a>
                                 <a data-toggle="modal" data-target="#myModal19" class="moda19" th:value="${tree.tree_id}">单个解锁</a>
                             </td>
                            </shiro:hasAnyRoles>
                        </tr>
                        </tbody>
                    </table>
                    <script>
                        $(".moda19").click(function () {
                            $.ajax({
                                url: "/admin/finance/mark/one?id="+$(this).attr("value"),
                                type: 'get',
                                async: false,
                                success: function (data) {
                                    if(data!=null){
                                        var str='';
                                        for(var i=0;i<data.length;i++){
                                            var tree=data[i];
                                            str+='<tr> <td>'+tree.remark+'</td>';
                                            str+=' <td>'+tree.serialNumber+'</td>';
                                            str+=' <td>'+tree.treeSpecies+'</td>';
                                            str+=' <td>'+tree.createtime+'</td>';
                                            str+=' <shiro:hasAnyRoles name="admin,finance"><td> ' +
                                                '<a href="/admin/finance/deblocking/one?tree_id='+tree.tree_id+'">解锁</a>' +
                                                '</td></shiro:hasAnyRoles></tr>';
                                        }
                                        document.getElementById('markall').innerHTML=str;
                                    }
                                },
                                error: function (xhr) {
                                    alert("error")
                                }
                            });
                        });
                    </script>
                </div>
            </div>
        </section>
        <div class="modal fade" id="myModal19" tabindex="-1" role="dialog" aria-labelledby="myModalLabel19" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    </div>
                    <table class="table table-striped table-hover">
                        <thead>
                        <tr>
                            <th class="hidden-sm-down">去向</th>
                            <th class="hidden-sm-down">位置</th>
                            <th class="hidden-sm-down">树种</th>
                            <th class="no-sort">过期时间</th>
                            <shiro:hasAnyRoles name="admin,finance">
                                <th class="no-sort">解锁</th>
                            </shiro:hasAnyRoles>
                        </tr>
                        </thead>
                        <tbody id="markall">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </main>
</div>
</body>
</html>